package com.ruoyi.project.men.service.impl;


import com.ruoyi.common.utils.bootdo.R;
import com.ruoyi.project.men.dao.*;
import com.ruoyi.project.men.domain.MenProductInfoDO;
import com.ruoyi.project.men.service.MenProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class MenProductInfoServiceImpl implements MenProductInfoService {
	@Autowired
	private MenProductInfoDao menProductInfoDao;
	@Autowired
	private MenSildeDao menSildeDao;
	@Autowired
	private MenProductTypeDao menProductTypeDao;
	@Autowired
	private MenProductTypeParamDao menProductTypeParamDao;
	@Autowired
	private MenProductFunctionDao menProductFunctionDao;
	@Autowired
	private MenProductAdvantageDao menProductAdvantageDao;
	@Autowired
	private MenRelatedCaseDao menRelatedCaseDao;
	@Autowired
	private MenRelatedGoodsDao menRelatedGoodsDao;
	
	@Override
	public MenProductInfoDO get(String id){
		return menProductInfoDao.get(id);
	}
	
	@Override
	public List<MenProductInfoDO> list(Map<String, Object> map){
		return menProductInfoDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return menProductInfoDao.count(map);
	}
	
	@Override
	public int save(MenProductInfoDO menProductInfo){
		return menProductInfoDao.save(menProductInfo);
	}
	
	@Override
	public int update(MenProductInfoDO menProductInfo){
		return menProductInfoDao.update(menProductInfo);
	}
	
	@Override
	public int remove(String id){
		return menProductInfoDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return menProductInfoDao.batchRemove(ids);
	}

    @Override
    public List<MenProductInfoDO> likeList(Map<String, Object> map){
        return menProductInfoDao.likeList(map);
    }
    @Override
    public int likeListCount(Map<String, Object> map){
        return menProductInfoDao.likeListCount(map);
    }

	@Override
	public List<Map<String, Object>> getProductNameByClassId(Map<String, Object> map) {
		return menProductInfoDao.getProductNameByClassId(map);
	}

	@Override
	public R getProductInfo(Map<String, Object> params) {
		//详情
		MenProductInfoDO menProductInfoDO = menProductInfoDao.get(params.get("productId").toString());

		Map<String,Object> map = new HashMap<>();
		map.put("status","0");
		/*//轮播图

		List<Map<String,Object>> sildeList = menSildeDao.getSildeByStatus(map);*/
		//产品类型
		List<Map<String,Object>> productTypeList = menProductTypeDao.getProductTypeByProductId(params);
		//产品类型参数
		if(productTypeList.size()>0){
			for (Map<String, Object> typeMap : productTypeList) {
				List<Map<String,Object>> typeParamList = menProductTypeParamDao.getByTypeId(typeMap.get("id").toString());
				typeMap.put("typeParamList",typeParamList);
			}
		}
		//功能设计
		List<Map<String,Object>> productFunctionList = menProductFunctionDao.getProductFunctionByProductId(params);
		//产品优势
		List<Map<String,Object>> productAdvantageList = menProductAdvantageDao.getProductAdvantageByProductId(params);
		//项目案例
		map.put("parentId",params.get("productId").toString());
		List<Map<String,Object>> productCaseList = menRelatedCaseDao.getCaseByProductId(map);
		//相关产品
		List<Map<String,Object>> productGoodsList = menRelatedGoodsDao.getGoodsByProductId(map);

		Map<String,Object> returnMap = new HashMap<>();
		returnMap.put("menProductInfo",menProductInfoDO);
		/*returnMap.put("sildeList",sildeList);*/
		returnMap.put("productTypeList",productTypeList);
		returnMap.put("productFunctionList",productFunctionList);
		returnMap.put("productAdvantageList",productAdvantageList);
		returnMap.put("productCaseList",productCaseList);
		returnMap.put("productGoodsList",productGoodsList);
		return R.ok().put("data",returnMap);
	}

}
